<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>axiethernet: xavb_example.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">axiethernet
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="pages.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xavb__example_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xavb_example.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file implements a simple example to show the usage of Audio Video Bridging (AVB) functionality of Axi Ethernet IP in loopback mode. </p>
<p>The example uses the PTP Timer and the PTP Rx interrupts. A PDelay_Req packet is sent and is received back (as we are in loopback mode). . After this loop backed PDelay_Req packet is received, a PDelay_Resp and PDelay_RespFollowUp packets are sent. These packets are also received. Since the source port identity of the received packets matches with our systems's own source port identity there is no further processing done.</p>
<dl class="section note"><dt>Note</dt><dd></dd></dl>
<p>This code assumes the processor type is Microblaze, Xilinx interrupt controller (XIntc) is used in the system , and that no operating system is used.</p>
<p>It also assumes that all the relevant AVB interrupts are properly connected to the Intc module.</p>
<p>The Ethernet AVB Endpoint functionality should be enabled in the Xilinx Axi Ethernet core for this example to work.</p>
<p>The Axi Ethernet is used with a GMII interface. The example initializes the GMII interface with 1000 Mbps speed.</p>
<p>IMPORTANT NOTE: The user must define the macro XAVB_CLOCK_LOCK_THRESHOLD in <a class="el" href="xavb_8h.html" title="This header file contains the identifiers and basic driver functions (or macros) that can be used to ...">xavb.h</a> to an appropriate value as relevant for the corresponding use case. Presently it is defined to 1000 ns which is typical for telecom industry. This macro is used to compare against the slave error as calculated every time after receiving 2 successive sync/followup frames. Slave error is the difference between master time duration and slave time duration as calculated for the time gap (the time it takes to receive two successive sync/follow up frames). If slave error is greater than the value defined in XAVB_CLOCK_LOCK_THRESHOLD, then master and slave clocks are unlocked. This means the node running this SW assumes that the peer is no more capable of processing 802.1as frames. The node running the SW then waits till it successful calculates the path delay (which essentially means the peer is again capable of processing 802.1as frames.</p>
<pre>
MODIFICATION HISTORY:</pre><pre>Ver   Who      Date     Changes
</p>
<hr/>
<p>
1.00a kag/asa  08/25/10 First release
3.00a asa        04/10/12 Disabled enabling of promiscuous mode. This is
                  required for AxiEthernet cores with version v3_01_a
                  onwards because of a change in the AVB implementation.
4.0   asa  03/06/14 Fix for CR 740863. Added a #warning message for
                          users of this example to take note of the fact that
                          we have just used a typical value for XAVB_CLOCK_LOCK_THRESHOLD
                and users may want to change it as per their requirements.
5.17  ml   11/15/23  Fix compilation errors reported with -std=c2x compiler flag
</pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a249ec82daff032bfe981d21980bae55c"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xavb__example_8c.html#a249ec82daff032bfe981d21980bae55c">AXIETHERNET_DEVICE_ID</a>&#160;&#160;&#160;XPAR_AXIETHERNET_0_DEVICE_ID</td></tr>
<tr class="memdesc:a249ec82daff032bfe981d21980bae55c"><td class="mdescLeft">&#160;</td><td class="mdescRight">The following constants map to the XPAR parameters created in the xparameters.h file.  <a href="#a249ec82daff032bfe981d21980bae55c">More...</a><br/></td></tr>
<tr class="separator:a249ec82daff032bfe981d21980bae55c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aa079ce6e3a9db05cda1d6f5173f747c2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xavb__example_8c.html#aa079ce6e3a9db05cda1d6f5173f747c2">AvbGMDiscontinuityHandler</a> (void *CallBackRef, u32 TimestampsUncertain)</td></tr>
<tr class="memdesc:aa079ce6e3a9db05cda1d6f5173f747c2"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is the handler which will be called if the PTP drivers identify a possible discontinuity in GrandMaster time.  <a href="#aa079ce6e3a9db05cda1d6f5173f747c2">More...</a><br/></td></tr>
<tr class="separator:aa079ce6e3a9db05cda1d6f5173f747c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xavb__example_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">This is the main function for the AVB example.  <a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br/></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a249ec82daff032bfe981d21980bae55c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define AXIETHERNET_DEVICE_ID&#160;&#160;&#160;XPAR_AXIETHERNET_0_DEVICE_ID</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The following constants map to the XPAR parameters created in the xparameters.h file. </p>
<p>They are defined here such that a user can easily change all the needed parameters in one place. </p>

<p>Referenced by <a class="el" href="xavb__example_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main()</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="aa079ce6e3a9db05cda1d6f5173f747c2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void AvbGMDiscontinuityHandler </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>CallBackRef</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>TimestampsUncertain</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function is the handler which will be called if the PTP drivers identify a possible discontinuity in GrandMaster time. </p>
<p>This handler provides an example of how to handle this situation - but this function is application specific.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">CallBackRef</td><td>contains a callback reference from the driver, in this case it is the instance pointer for the AVB driver. </td></tr>
    <tr><td class="paramname">TimestampsUncertain</td><td>- a value of 1 indicates that there is a possible discontinuity in GrandMaster time. A value of 0 indicates that Timestamps are no longer uncertain.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This Handler need to be defined otherwise the XAvb_StubHandler will generate an error </dd></dl>

<p>Referenced by <a class="el" href="xavb__example_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main()</a>.</p>

</div>
</div>
<a class="anchor" id="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This is the main function for the AVB example. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">None.</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>- XST_SUCCESS to indicate success.<ul>
<li>XST_FAILURE to indicate failure</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This example will be in a infinite loop if the HW is not working properly and if the interrupts are not received. </dd></dl>

<p>References <a class="el" href="xavb__example_8c.html#aa079ce6e3a9db05cda1d6f5173f747c2">AvbGMDiscontinuityHandler()</a>, <a class="el" href="xavb__example_8c.html#a249ec82daff032bfe981d21980bae55c">AXIETHERNET_DEVICE_ID</a>, <a class="el" href="struct_x_avb___config.html#a8f161e4fe6ff1843746adbd93a173241">XAvb_Config::BaseAddress</a>, <a class="el" href="struct_x_axi_ethernet___config.html#ae3fc04787ba28bb14e6c2add45c0c086">XAxiEthernet_Config::BaseAddress</a>, <a class="el" href="struct_x_avb___port_identity.html#ad7e78ca34d8fcbecf410f8d748177e0e">XAvb_PortIdentity::ClockIdentityLower</a>, <a class="el" href="struct_x_avb___port_identity.html#aa1435c872067f98c7998a4b98b792112">XAvb_PortIdentity::ClockIdentityUpper</a>, <a class="el" href="struct_x_avb.html#a004789c582ac680a57d708f86c13ab9f">XAvb::Config</a>, <a class="el" href="struct_x_avb___config.html#a7ad0d29a0a15fb4d3214c2e42e9af553">XAvb_Config::DeviceId</a>, <a class="el" href="struct_x_axi_ethernet___config.html#a7dc877a54e0c85e0ca14ba977041bcb4">XAxiEthernet_Config::DeviceId</a>, <a class="el" href="struct_x_avb___port_identity.html#adbb184a9b5875775835442cf06a25800">XAvb_PortIdentity::PortNumber</a>, <a class="el" href="xavb_8c.html#af8ddc8d42f610c49547f6cf4778629d1">XAvb_CfgInitialize()</a>, <a class="el" href="xavb_8h.html#a664d83b2f34093d6000f3ea2facef449">XAvb_ReorderWord()</a>, <a class="el" href="xavb_8c.html#af24c248c31c6c45cdb8a46f82de175c5">XAvb_Reset()</a>, <a class="el" href="xavb_8h.html#a3c8e2297936bf5abb7f206b365611b30">XAvb_SetGMDiscontinuityHandler()</a>, <a class="el" href="xavb_8h.html#a42cd78e966447edcb45a0f419cc84cb8">XAvb_SetupSourcePortIdentity()</a>, <a class="el" href="xavb_8c.html#a8657704dc9974d465536615ebbeb79d9">XAvb_Start()</a>, <a class="el" href="xavb_8h.html#a1fafde8d597983f3e827b93fcc8e3c8a">XAvb_WriteToMultipleTxPtpFrames()</a>, <a class="el" href="group__axiethernet.html#gabe257efe600df43d8148c772ea3878f9">XAxiEthernet_CfgInitialize()</a>, and <a class="el" href="group__axiethernet.html#ga781a4d89a7a3a9d59ac8921ba66b353d">XAxiEthernet_LookupConfig()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
